package com.easyfun.healthmagicbox.comm.json;

import org.json.JSONException;
import org.json.JSONObject;

import com.easyfun.healthmagicbox.pojo.DataReferenceDescription;

public class ReferenceDataJsonWrapper <T extends JsonWrapper,E> 
extends AbstractJsonWrapper<T, DataReferenceDescription>{
	public ReferenceDataJsonWrapper(DataReferenceDescription pp)
	{
		super(pp);
		this.mpp = pp;
	}
 
	public ReferenceDataJsonWrapper()
	{
		
	}
 
    public void deserializeFromObj(JSONObject obj) throws JSONException {
		mpp = new DataReferenceDescription();
		
		if (obj.isNull("id"))
    	{
    		mpp.setSyncId(Integer.valueOf(0));
    	}else {
    		mpp.setSyncId(obj.getInt("id"));
    	}

		mpp.setGender(obj.getInt("gender"));
		mpp.setReferenceDataType(obj.getInt("referenceDataType"));
		mpp.setReferenceDataDescription(obj.getString("refernceDataDescription"));
		mpp.setDependencyLowerLimitData((float)(obj.getInt("dependencyLowerLimitData")));
    	mpp.setDependencyUpperLimitData((float)(obj.getInt("dependencyUpperLimitData")));
    	mpp.setUpperLimitData((float)(obj.getInt("upperLimitData")));
    	mpp.setLowerLimitData((float)(obj.getInt("lowerLimitData")));
    	
    }
 
 
    public JSONObject serializeToObj() throws JSONException {
        JSONObject serializedObj = new JSONObject();
        serializedObj.put("clientID", mpp.getId());
        serializedObj.put("referenceDataType", mpp.getReferenceDataType());
        serializedObj.put("gender", mpp.getGender());
        serializedObj.put("dependencyLowerLimitData", mpp.getDependencyLowerLimitData());
        serializedObj.put("dependencyUpperLimitData", mpp.getDependencyUpperLimitData());
        serializedObj.put("upperLimitData", mpp.getUpperLimitData());
        serializedObj.put("lowerLimitData", mpp.getLowerLimitData());
        serializedObj.put("refernceDataDescription", mpp.getReferenceDataDescription());
 
        return serializedObj;
    }
    
  
}
